package com.thinkcube.edutainment.adapters;

import java.util.List;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.thinkcube.edutainment.domain.data.CourseData;
import com.thinkcube.edutainment.service.viewitem.MyCourseItem;
import com.thinkcube.edutainment.service.viewitem.MyCourseItem_;



@EBean
public class MyCourseAdapter extends BaseAdapter {

	List<CourseData> courseDataList;

	@RootContext
	Context context;

	@Override
	public View getView(final int position, final View convertView,
			final ViewGroup parent) {

		MyCourseItem personItemView;
		if (convertView == null) {
			personItemView = MyCourseItem_.build(context);
		} else {
			personItemView = (MyCourseItem) convertView;
		}

		personItemView.bind(getItem(position));

		return personItemView;
	}


	public List<CourseData> getCourseDataList() {
		return courseDataList;
	}

	public void setCourseDataList(List<CourseData> courseDataList) {
		this.courseDataList = courseDataList;
	}

	@Override
	public int getCount() {
		return courseDataList.size();
	}

	@Override
	public CourseData getItem(final int position) {
		return courseDataList.get(position);
	}

	@Override
	public long getItemId(final int position) {
		return position;
	}

}
